import React,{Component} from 'react'
import {Text,View,StyleSheet,TextInput,Button} from 'react-native'
import ScrollableTabView, {ScrollableTabBar} from 'react-native-scrollable-tab-view'
import DataReponsitory from '../expand/dao/DataReponsitory'

const URL = 'https://api.github.com/search/repositories?q=';
const QUERY_STR = '&sort=stars';
// const dataReponsitory = new DataReponsitory

export default class Popular extends Component {
    static navigationOptions = ({
        title: '最热'
    })

    constructor(props){
        super(props)
        this.dataReponsitory = new DataReponsitory
        this.state = {
            result:'',
        }
    }

    onload = ()=>{
        let url = `${URL}${this.inputText}${QUERY_STR}`
        this.dataReponsitory.feactNetRepository(url)
                        .then(result=>{
                            this.setState({
                                result:JSON.stringify(result)
                            })
                        })
                        .catch(error=>{
                            this.setState({
                                result:JSON.stringify(error)
                            })
                        })
    }

    render() {
        return (
            <View style={styles.container}>
                <ScrollableTabView>
                <Text tabLable='IOS'>IOS</Text>
                <Text tabLable='Java'>Java</Text>
                <Text tabLable='Andriod'>Andriod</Text>
                <Text tabLable='JavaScript'>JS</Text>
                </ScrollableTabView>
            </View>
        )
    }
}

const styles = StyleSheet.create({
    container:{
        flex: 1,
        alignItems: 'center'
    }
})